package com.jason.ordermd.controller;

import com.jason.ordermd.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
@RequestMapping("/orderService")
public class OrderController {
    private static final Logger logger = LoggerFactory.getLogger(OrderController.class);
    @Autowired
    private OrderService orderService;

    @GetMapping("/payOrder")
    public String payOrder(){
        logger.info("payOrder begin");
         orderService.payOrder();
        logger.info("payOrder end");
         return "success";
    }

    @GetMapping("/payOrderRollBack")
    public String payOrderRollBack(){
        logger.info("payOrderRollBack begin");
        orderService.payOrderRollBack();
        logger.info("payOrderRollBack end");
        return "success";
    }

    @GetMapping("/testThrowException")
    public String testThrowException(){
        logger.info("payOrderRollBack begin");
        orderService.testThrowException();
        logger.info("payOrderRollBack end");
        return "success";
    }
}
